﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Skynet.C2SModule.Views.AuthorsDSMgmt
{
    /// <summary>
    /// Interaction logic for AuthorsViewMgmt.xaml
    /// </summary>
    public partial class AuthorsViewMgmt : Page
    {
        public AuthorsViewMgmt()
        {
            InitializeComponent();
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {            
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                var ds = this.Resources["skynetLibraryDS"] as Models.SkynetLibraryDS;
                var aut = new Models.SkynetLibraryDSTableAdapters.AuthorsTableAdapter();
                aut.Fill(ds.Authors);

                var bta = new Models.SkynetLibraryDSTableAdapters.BooksTableAdapter();
                bta.Fill(ds.Books);  

                var avs = this.Resources["authorsViewSource"] as CollectionViewSource;
                avs.Source = ds.Authors;

                //var bvs = this.Resources["booksViewSource"] as CollectionViewSource;
                //avs.Source = avs;


            
            // 	System.Windows.Data.CollectionViewSource myCollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["Resource Key for CollectionViewSource"];
            // 	myCollectionViewSource.Source = your data
            }
        }
        //next
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            var avs = this.Resources["authorsViewSource"] as CollectionViewSource;
            avs.View.MoveCurrentToNext();  
        }
        //previus
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            var avs = this.Resources["authorsViewSource"] as CollectionViewSource;
            avs.View.MoveCurrentToPrevious();  
        }
    }
}
